package com.yanqu.road.server.cmd.player;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_SEARCH_PLAYER_RESP, desc = "跨服查找玩家响应")
public class CrossSearchPlayerRespCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PlayerProto.CrossSearchPlayerRespMsg reqMsg = PlayerProto.CrossSearchPlayerRespMsg.parseFrom(packet.getBytes());
        PlayerProto.SearchPlayerRespMsg.Builder respMsg = PlayerProto.SearchPlayerRespMsg.newBuilder();
        respMsg.setRet(reqMsg.getRet());
        if(0 == reqMsg.getRet()){
            respMsg.setPlayerData(reqMsg.getPlayerData());
        }
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.U_SEARCH_PLAYER, respMsg);
        MessageHelper.sendPacket(reqMsg.getServerId(), reqMsg.getUserId(), pbMsg);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
